package cn.tedu.ivos.geofence.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceParam;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceQuery;
import cn.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import cn.tedu.ivos.geofence.service.GeofenceService;
import cn.tedu.ivos.vehicle.pojo.dto.VehicleQuery;
import cn.tedu.ivos.vehicle.pojo.dto.VehicleSaveParam;
import cn.tedu.ivos.vehicle.pojo.vo.VehicleVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RestController
@RequestMapping("/v1/geofence")
public class GeofenceController {

    @Autowired
    private GeofenceService geofenceService;

    /**
     * 查询操作
     * @param geofenceQuery
     * @return
     */
    @GetMapping("select")
    public JsonResult select(GeofenceQuery geofenceQuery){
        log.debug("{}",geofenceQuery);
       List<GeofenceVO> geofenceVO= geofenceService.select(geofenceQuery);
        return JsonResult.ok(geofenceVO);
    }
    /**
     * 查询操作
     */
    @GetMapping("vehicle")
    public JsonResult selectvehicle(VehicleQuery vehicleQuery){
        log.debug("{}",vehicleQuery.getGeofenceId());
       List<VehicleVO> vehicleVO= geofenceService.selectvehicle(vehicleQuery);
        return JsonResult.ok(vehicleVO);
    }
    /**
     * 修改车辆电子围栏绑定状态
     */
    @PostMapping("vehicle/updata")
    public JsonResult updateVehicle(Long geofenceId){
        log.debug("{}",geofenceId);
        geofenceService.updateVehicle(geofenceId);
        return JsonResult.ok();
    }
    @PostMapping("vehicle/updatanew")
    public JsonResult updata(Long id, Long geofenceId){
        log.debug("{}",id);
            geofenceService.updateVehiclenew(id,geofenceId);
        return JsonResult.ok();
    }
    @PostMapping("delete")
    public JsonResult delete(Long id){
        log.debug("{}",id);
        geofenceService.delete(id);
        return JsonResult.ok();
    }
    @PostMapping("updataGeofence")
    public JsonResult updataGeofence(Long id,String status){
        log.debug("{},{}",id,status);
        geofenceService.updataGeofence(id,status);
        return JsonResult.ok();
    }
    @PostMapping("save")
    public JsonResult Insert(GeofenceParam geofenceParam){
        log.debug("{}",geofenceParam);
        geofenceService.Insert(geofenceParam);
        return JsonResult.ok();
    }

}
